package com.springbootblog.controller.fontend;

import com.springbootblog.service.fontend.ImUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * wangeditor部分接口
 * @className AboutController
 * @author camellia
 * @email 805795955@qq.com
 * @date 2024/01/01
 * @version 1.0
 */
@RequestMapping("java")
@RestController
//@CrossOrigin(origins="*",maxAge=3600)
public class ImUploadController
{
    /**
     * 自动装载（service接口注入）
     */
    @Autowired
    private ImUploadService imUploadService;

    /**
     * 上传图片
     * @return
     */
    @PostMapping("imUpload/uploadImage")
    public Map<String,Object> uploadImage(@RequestParam(value = "file",required = false) MultipartFile file, HttpServletRequest request)
    {
        Map<String,Object> result = imUploadService.uploadImage(file,request);
        return result;
    }

    /**
     * 上传视频
     * @return
     */
    @PostMapping("imUpload/uploadVideo")
    public Map<String,Object> uploadVideo(@RequestParam(value = "file",required = false) MultipartFile file, HttpServletRequest request)
    {
        Map<String,Object> result = imUploadService.uploadVideo(file,request);
        return result;
    }

}
